package com.ostrich.cloud.ostrichGoodsService.app.ApiImp;

import com.ostrich.cloud.ostrichGoodsService.infra.model.GrounpBy;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.client.producer.SendCallback;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@Slf4j
public class TestController {

    @Resource
    private RocketMQTemplate rocketMQTemplate;
    @GetMapping("test")
    public String test(){

        rocketMQTemplate.asyncSend("Grounp_group", MessageBuilder.withPayload(new GrounpBy()).build(), new SendCallback() {
            @Override
            public void onSuccess(SendResult sendResult) {
                log.info("开始发送消息{}",sendResult);
            }

            @Override
            public void onException(Throwable throwable) {

            }
        },1000,2);


        return "success";
    }
}
